from common.http_request import HttpRequest
import time


class Server(HttpRequest):

    # 获取下列列表数据
    def area_dqjj_select_list(self):
        res = self.request(
            url="https://data.stats.gov.cn/easyquery.htm",
            method="GET",
            params={
                "m": "getOtherWds",
                "dbcode": "fsnd",
                "rowcode": "reg",
                "colcode": "sj",
                "wds": "[]",
                "k1": str(int(round(time.time() * 1000)))
            }
        )
        return self.json(res)

    # 区域数据获取服务
    def area_dqjj_datas(self, type, times='2022'):
        res = self.request(
            url="https://data.stats.gov.cn/easyquery.htm",
            method="GET",
            params={
                "m": "QueryData",
                "dbcode": "fsnd",
                "rowcode": "reg",
                "colcode": "sj",
                "wds": '[{"wdcode":"zb","valuecode": "' + type + '"}]',
                "dfwds": '[{"wdcode":"sj", "valuecode":"' + times + '"}]',
                "k1": str(int(round(time.time() * 1000))),
                "h": 1
            }
        )
        return self.json(res)
